<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function demo(num) {
            // 设置临界条件
            if (num < 1) {
                return 1;
            }
            // 递归函数就是在函数内部调用该函数
            return num + demo(num-1);
        }
        console.log(demo(5));
    </script>
</body>
</html>